
public class Player {
	static double dirX = 0;
	static double dirY = 0;
	static boolean onGround = false;
	static boolean isMoving = false;
	static boolean nextTile[] = new boolean[4];
	
	
	


	
	
	public static void position(){
		checkBlock();
		Var.PlayerY += dirY;
		Var.PlayerX += dirX;
		if(nextTile[0] == false){
			onGround = false;
			if(dirY >= 5){
				dirY = 5;
			}else{
				dirY += 0.5;
			}
		}else{
			dirY = 0;
			if(onGround == false){
				snap();
				onGround = true;
			}
		}
		if(nextTile[1] == false){
			Var.PlayerX += dirX;
		}else{
			dirX = 0;
			snap();
		}
	}
	public static void move (int key){
		if(key == 1){
			if(onGround == true){
				jump();
			}
		}
		if(key == 2){
			dirX = 1;
			isMoving = true;
		}
		if(key == 3){
			dirX = -1;
			isMoving = true;
		}
	}
	public static void stop (int key){
		if(key == 1){
			
		}else if(key == 2){
			isMoving = false;
		}else if(key == 3){
			isMoving = false;
		}
	}
	
	public static void jump(){
		dirY = -50;
		onGround = false;
	}
	
	
	public static void snap(){
		
		Var.PlayerY = (int)(Var.PlayerY/32)*32;
		Var.PlayerX = (int)(Var.PlayerX/32)*32;
	}
	
	public static void checkBlock(){
		int x =(int)(Var.PlayerX/32);
		int y =(int)(Var.PlayerY/32);
		
		if(Var.isSolid[y + 1][x] == true){
			nextTile[0] = true;
		}else{
			nextTile[0] = false;
		}
		
		if(Var.isSolid[y][x+1] == true){
			nextTile[1] = true;
		}else{
			nextTile[1] = false;
		}
		if(Var.isSolid[y][x-1] == true){
			nextTile[2] = true;
		}else{
			nextTile[2] = false;
		}

	}
}
